/**
 * Created by lucah on 2018/9/15.
 */

//基类
class DrawBase{
    constructor(canvas, context,color) {
        this.canvas = canvas;
        this.color = color;
    }
};

//直线的实现
class line extends DrawBase{
    //构造方法
    constructor(canvas,color) {
        super(canvas, color); // 记得用super调用父类的构造方法!
    }
    drawing(){
        //绘制2d对象
        var context = document.getElementById(this.canvas).getContext("2d");
        context.beginPath();
        context.strokeStyle = this.color;
        context.moveTo(50, 50);
        context.lineTo(400, 200);
        context.stroke();
    };
};



$("#line").on("click",function () {
    let lineDraw = new line();
    lineDraw.canvas="myCanvas";
    lineDraw.color=$("#color").val();
    lineDraw.drawing();
});


